home *** CD-ROM | disk | FTP | other *** search
- //////////////////////////////////////////////////
- //
- // ADOBE SYSTEMS INCORPORATED
- // Copyright 2002 Adobe Systems Incorporated
- // All Rights Reserved
- //
- // NOTICE: Adobe permits you to use, modify, and
- // distribute this file in accordance with the terms
- // of the Adobe license agreement accompanying it.
- // If you have received this file from a source
- // other than Adobe, then your use, modification,
- // or distribution of it requires the prior
- // written permission of Adobe.
- //
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // Simple Animation.js
- //
- // DESCRIPTION
- //
- // This script demonstrates how to move an object an additional
- // 100,100 pixels across 12 frames.
- //
- // HOW TO USE
- //
- // Create any object and select it in the Composition.
- // Select Automation > Run Automation Scripts > Simple Animation.js
- // Click on Preview Mode to view the object animation !
- //
- //////////////////////////////////////////////////
-
- // Main Code [Execution of script begins from here]
-
- // Check if any composition is open
- if(application.compositions.length > 0){
- comp = application.currentComposition;
- if(comp.selection.length >= 1){ // Checks if at least one object is selected
- var objs = comp.selection; // Store all selected objects in the array objs
-
- for(var i=0 ; i < objs.length ; i++){
- // Assign the objects in objs, one by one to target and apply complex animation to them
- target = objs[i];
- application.currentComposition.saveSelection(); // saves the current selection
- simpleAnimation(target, 100, 100, 12); // Function complexAnimation called
- application.currentComposition.restoreSelection(); // restores the saved selection
- }
- }
- else{ // If no objects are selected brings the Console window up
- Console.show();
- // Writes to the Console
- Console.write("Please select the objects to apply the Animation and run the script again.\n");
- }
- }
- else{// if no composition open
- // opens a new composition
- comp = application.newComposition();
- Console.show();
- Console.write("New Composition opened\nPlease create and select the objects to apply the Animation and run the script again.\n");
- }
-
-
- // Add your own functions here
-
- //////////////////////////////////////////////////
- //
- // simpleAnimation:
- // Changes the location of the target
- //
- // targets: the object whose location we want to change
- // xDelta: change in x location
- // yDelta: change in y location
- // frames: Total frames across which the object moves.
- //
- //////////////////////////////////////////////////
-
- function simpleAnimation(target, xDelta, yDelta, frames)
- {
- var x_original; // variable for the original x position
- var y_original; // variable for the original y position
- var frame0; // The initial frame to start the animation from -- also the current frame
-
- frame0 = target.startFrame; // Take the current frame value and store it
- x_original = target.position.x; // store original x position
- y_original = target.position.y; // store original y position
-
- target.stopwatch.position = true; // turn on the stopwatch for position
-
- // Note: The initial positions are not stored by turning on the stopwatch.
- // The stopwatch only records changes AFTER it's been turned on.
-
- target.position.x = x_original;
- target.position.y = y_original;
-
- target.currentFrame = frame0+frames;// Advance to frame0+frames, here 0+12=12
- // frame0 is 0 assuming the current Time Marker/Indicator was at position 0 when you executed
- // this script.
- target.position.x += xDelta; // Add pixels to be advanced
- target.position.y += yDelta;
- }
-
-